//
// Created by 11571 on 2024/2/11.
//

#include "lv_page_menu.h"

static lv_obj_t * obj_menu_list;

lv_obj_t * ui_page_menu;

extern lv_ft_info_t font_info_72;
extern lv_ft_info_t font_info_40;
extern lv_ft_info_t font_info_20;

void lv_page_menu_create(void)
{
    ui_page_menu = lv_obj_create(NULL);

    obj_menu_list = lv_obj_create(ui_page_menu);
    lv_obj_remove_style_all(obj_menu_list);
    lv_obj_set_size(obj_menu_list, 466, LV_SIZE_CONTENT);
    lv_obj_set_pos(obj_menu_list, 8, 84);
    lv_obj_set_flex_flow(obj_menu_list, LV_FLEX_FLOW_ROW_WRAP);
    lv_obj_set_style_flex_main_place(obj_menu_list, LV_FLEX_ALIGN_START, 0);

    LV_IMG_DECLARE(icon_home)
    LV_IMG_DECLARE(icon_reboot)
    LV_IMG_DECLARE(icon_weather)
    uint32_t i;
    for(i = 0; i < 13; i++) {
        lv_obj_t * obj_menu_item = lv_obj_create(obj_menu_list);
        lv_obj_remove_style_all(obj_menu_item);
        lv_obj_set_flex_flow(obj_menu_item, LV_FLEX_FLOW_COLUMN);
        lv_obj_set_size(obj_menu_item, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
        lv_obj_add_flag(obj_menu_item, LV_OBJ_FLAG_CHECKABLE);
        lv_obj_set_style_pad_all(obj_menu_item, 16, 0);

        lv_obj_t * img = lv_img_create(obj_menu_item);
        if(i % 3 == 0) {
            lv_img_set_src(img, &icon_home);
        } else if(i % 3 == 1) {
            lv_img_set_src(img, &icon_reboot);
        } else if(i % 3 == 2) {
            lv_img_set_src(img, &icon_weather);
        }

        lv_obj_t * label = lv_label_create(obj_menu_item);
        lv_label_set_text_fmt(label, "测试", i);
        lv_obj_set_width(label, 57);
        lv_obj_set_style_text_font(label, font_info_20.font, 0);
        lv_obj_set_style_text_color(label, lv_color_make(0, 191, 153), 0);
        lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0);
    }
}

void lv_page_menu_del(void)
{}